package demo0;

public class DeckOfCards_0311 {
    private Card_0311[] cards;
    private String[] suis = {"黑桃", "红桃", "梅花", "方块"};
    public DeckOfCards_0311() {
        cards = new Card_0311[52];
        for (int i = 0; i < 4; i++) {
            for (int j = 1; j <= 13; j++) {
                cards[i * 13 + j - 1] = new Card_0311(suis[i], j);
            }
        }
    }
    public void shuffle() {
        for (int i = 0; i < 52; i++) {
            int j = (int)(Math.random() * 52);
            Card_0311 tmp = cards[i];
            cards[i] = cards[j];
            cards[j] = tmp;
        }
    }
    public Card_0311[][] fapai () {
        Card_0311[][] personCard = new Card_0311[4][13];
        for (int j = 0; j < 13; j++) {
            for (int i = 0; i < 4; i++) {
                personCard[i][j] = cards[j * 4 + i];
            }
        }
        return personCard;
    }
    public void print () {
        for (int i = 0; i < 52; i++) {
            System.out.print(cards[i].getSuit() + cards[i].getNum() + " ");
        }
        System.out.println();
    }
}
